package packge.io;

import java.io.*;

class IOTest7 {
	public static void main(String st[]) throws Exception {
		File f = new File("D:\\JLC\\package\\io");
		String files[] = f.list();
		for (int i = 0; i < files.length; i++) {
			System.out.println(files[i]);
		}
		System.out.println("**************************************************");
		File roots[] = File.listRoots();
		for (int i = 0; i < roots.length; i++) {
			System.out.println(roots[i]);
		}
		File fs[] = f.listFiles(new ExtFilter("txt"));
		System.out.println("******  TXT  *******");
		for (int i = 0; i < fs.length; i++) {
			System.out.println(fs[i]);
		}
		fs = f.listFiles(new ExtFilter("java"));
		System.out.println("************  JAVA   ************");
		for (int i = 0; i < fs.length; i++) {
			System.out.println(fs[i]);
		}
		System.out.println("---------------     Completed      ------------------");
	}
}

class ExtFilter implements FileFilter {
	String ext;

	ExtFilter(String ext) {
		this.ext = ext;
	}

	public boolean accept(File file) {
		return file.getName().endsWith(ext);
	}
}